import os
import sys
import time

from PyQt5.QtWidgets import QApplication,QMainWindow,QFileDialog
from PyQt5.uic import loadUi

from mier_sdk.mier_usb_wda import BaseClient
from mier_sdk.screen_ui import Ui_MainWindow
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import QtWidgets, QtCore, QtGui
import cv2
path = os.getcwd()
class Creat_Screen(QMainWindow):


    def __init__(self,udid,name,parent = None):
        self.udid = udid
        self.name = name
        super(Creat_Screen, self).__init__(parent)

        print('====================软件运行====================')
        loadUi(os.path.join(path, r'../mier_sdk/untitled.ui'), self)
        self.setWindowTitle(self.name)
        print('111')
        self.wda_self2 = BaseClient(udid=self.udid, port=9100)
        self.wda_self2.start()
        self.wda_self2.img_view.connect(self.view_imgs)

    def view_imgs(self, img):
        self.label.setScaledContents(True)
        frame = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)

        img1 = QImage(frame.data, frame.shape[1], frame.shape[0], QImage.Format_RGB888)
        self.label.setPixmap(QPixmap.fromImage(img1))



